import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import GoodsList from "../views/GoodsList";
import Login from "../views/Login";
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: '商户登录',
    component: Login,
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children:[
      {path: '/list', name: '列表', component: GoodsList}
    ]
  },
]

const router = new VueRouter({
  routes
})

export default router
router.beforeEach(function (to, from, next) {
  if(to.path=="/"){
    return next();
  }
  var seller=sessionStorage.getItem("user");
  if(seller){
    return next();
  }
  return next("/");

})
